class SessionsController < ApplicationController
  skip_before_filter :require_login,only: [:new,:create,:destroy]
  def new
    @user = User.new
    render layout: 'user_form'
  end
  def create
    if @user = login(params[:session][:email],params[:session][:password],params[:session][:remember])
      flash[:success] = "登录成功"
      logger.info "user id : #{current_user.id}"
      respond_to do |format|
        format.html { redirect_back_or_to root_path }
        format.js
      end
    end
  end

  def destroy
    logout
    redirect_to root_path
    flash[:success] = "退出成功"
  end
end
